#include "core_portme.h"
#include "coremark.h"
#include "util.h"

ee_u32 default_num_contexts = 1;
static unsigned long long Start;
static unsigned long long End;

void portable_init(core_portable *p, int *argc, char *argv[])
{
	if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
		ee_printf("ERROR! Please define ee_ptr_int to a type that holds a pointer!\n");
	}
	if (sizeof(ee_u32) != 4) {
		ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
	}
	p->portable_id=1;
}

void portable_fini(core_portable *p)
{
	p->portable_id=0;
}

void start_time()
{
	Start = read_csr(mcycle);
}

void stop_time()
{
	End = read_csr(mcycle);
}

CORE_TICKS get_time()
{
	return End - Start;
}

#define HZ 5000

secs_ret time_in_secs(CORE_TICKS ticks)
{
	secs_ret retval= ticks / (secs_ret)HZ;
	return retval;
}

#if (SEED_METHOD==SEED_VOLATILE)
#if VALIDATION_RUN
        volatile ee_s32 seed1_volatile=0x3415;
        volatile ee_s32 seed2_volatile=0x3415;
        volatile ee_s32 seed3_volatile=0x66;
#endif
#if PERFORMANCE_RUN
        volatile ee_s32 seed1_volatile=0x0;
        volatile ee_s32 seed2_volatile=0x0;
        volatile ee_s32 seed3_volatile=0x66;
#endif
#if PROFILE_RUN
        volatile ee_s32 seed1_volatile=0x8;
        volatile ee_s32 seed2_volatile=0x8;
        volatile ee_s32 seed3_volatile=0x8;
#endif
        volatile ee_s32 seed4_volatile=ITERATIONS;
        volatile ee_s32 seed5_volatile=0;
#endif

